﻿<Window x:Class="F5.BigIp.LocalTrafficManager.UI.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:views="clr-namespace:F5.BigIp.LocalTrafficManager.UI.Views"
        xmlns:local="clr-namespace:F5.BigIp.LocalTrafficManager.UI.ViewModels"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        Title="{Binding Title}" 
        Height="500" 
        Width="700" 
        ResizeMode="CanResizeWithGrip">

    <Window.DataContext>
        <local:MainViewModel />
    </Window.DataContext>

    <Window.InputBindings>
        <KeyBinding Key="F5" Command="{Binding RefreshPoolMembersCommand}" CommandParameter="{Binding SelectedPool}" />
    </Window.InputBindings>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <i:InvokeCommandAction Command="{Binding LoadDevicesCommand}" CommandParameter="{Binding LoadBalancers}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>

    <DockPanel>

        <views:MainMenuControl DockPanel.Dock="Top" DataContext="{Binding}" x:Name="MainMenu"/>

        <views:ToolBarControl DockPanel.Dock="Top" DataContext="{Binding}" />

        <views:StatusBarControl DockPanel.Dock="Bottom" DataContext="{Binding}" />

        <views:PoolControl DockPanel.Dock="Left" DataContext="{Binding}">
            <views:PoolControl.Style>
                <Style TargetType="views:PoolControl">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Pools}" Value="{x:Null}">
                            <Setter Property="Visibility" Value="Hidden"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding HidePools}" Value="True">
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </views:PoolControl.Style>
        </views:PoolControl>

        <views:PoolMemberControl DataContext="{Binding}">
            <views:PoolMemberControl.Style>
                <Style TargetType="views:PoolMemberControl">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding PoolMembers}" Value="{x:Null}">
                            <Setter Property="Visibility" Value="Hidden"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </views:PoolMemberControl.Style>
        </views:PoolMemberControl>

    </DockPanel>

</Window>
